package training.osms.view.category;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import training.osms.controller.category.CategoryController;
import training.osms.model.category.Category;
import training.osms.view.OsmsUtil;


@ManagedBean
@SessionScoped
public class DeleteCategoryForm {

	private Category category;
	private boolean catSaved;

	public DeleteCategoryForm(){
		this.category = new Category();
	}
	
	public String initialize(Category category){
		this.category = category;
		this.catSaved = false;
		return "deleteCategory";
	}
	
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
	public void deleteCategory(){
		CategoryController controller = new CategoryController();
		controller.deleteCategory(category);
		this.catSaved = true;
		OsmsUtil.sendMessage("Category successfully deleted.", OsmsUtil.INFO);
	}

	public boolean getCatSaved() {
		return catSaved;
	}

	public void setCatSaved(boolean catSaved) {
		this.catSaved = catSaved;
	}
	
}
